using IQIGame.Onigao.Framework;
using IQIGame.Onigao.Game;
using UnityEngine;

namespace IQIGame.Onigao.GamePlay
{
    public class UIBattleOrderItem : UIBaseNode
    {
        protected UIB_UIBattleOrderItem ui { get; set; }
        public long uid { get; private set; }

        #region Template Generate,don't modify

        protected partial class UIB_UIBattleOrderItem
        {
            #region ObjectBinding Generate
            public GameObject self { protected set; get; }
            public GameObject enemy { protected set; get; }
            public IQIGame.Onigao.Framework.ExImage icon_Self { protected set; get; }
            public IQIGame.Onigao.Framework.ExImage icon_Enemy { protected set; get; }
            protected virtual void InitBinding(ObjectBinding __binding)
            {
                var __tbv0 = __binding.GetVariableByName("self");
                this.self = __tbv0.GetValue<GameObject>();
                var __tbv1 = __binding.GetVariableByName("enemy");
                this.enemy = __tbv1.GetValue<GameObject>();
                var __tbv2 = __binding.GetVariableByName("icon_Self");
                this.icon_Self = __tbv2.GetValue<IQIGame.Onigao.Framework.ExImage>();
                var __tbv3 = __binding.GetVariableByName("icon_Enemy");
                this.icon_Enemy = __tbv3.GetValue<IQIGame.Onigao.Framework.ExImage>();
            }
            #endregion ObjectBinding Generate
        }

        #endregion Template Generate,don't modify

        protected override void BeforeInit()
        {
            ui = new UIB_UIBattleOrderItem();
            ui.StartBinding(gameObject);
        }

        /// <summary>
        /// 可以自定义修改的
        /// </summary>
        protected partial class UIB_UIBattleOrderItem
        {
            public virtual void StartBinding(GameObject __go)
            {
                var binding = __go.GetComponent<ObjectBinding>();
                if (binding != null)
                {
                    this.InitBinding(binding);
                }
            }
        }

        protected override void OnInit()
        {

        }

        protected override void OnShow()
        {

        }

        protected override void OnHide()
        {

        }

        public void SetItem(long uid, Sprite icon, bool bEnemy)
        {
            this.uid = uid;
            this.ui.self.SetActive(!bEnemy);
            this.ui.enemy.SetActive(bEnemy);
            if (!bEnemy)
            {
                this.ui.icon_Self.sprite = icon;
            }
            else
            {
                this.ui.icon_Enemy.sprite = icon;
            }
        }

        protected override void OnDispose()
        {

        }
    }
}